//
//  CustomVoiceView.swift
//  imprint
//
//  Created by 小柠檬🍋 on 2025/1/17.
//

import SwiftUI

//自定义音色
struct CustomVoiceView: View {
    @ObservedObject var viewModel : MakeVoiceViewModel
    @ObservedObject var viewModelDone : MakeVoiceDoneViewModel
    @State private var selectedOption = "未完成"
    let options = ["未完成","已完成"]
    let options2 = ["已完成"]

    var body: some View {
        VStack {
            if !isExamine() {
                Picker("未完成", selection: $selectedOption) {
                    ForEach(options,id : \.self){ option in
                        Text(option)
                    }
                }.pickerStyle(.segmented)
                    .padding(EdgeInsets(top: 0, leading: 20, bottom: 10, trailing: 20))
            }
            // Spacer 用于占据剩余空间
            Spacer()
            Group {
                if selectedOption == "未完成" {
                    CrowdView(viewModel: viewModel).frame(maxHeight: .infinity)
                } else if selectedOption == "已完成" {
                    CrowdDoneView(viewModel: viewModelDone).frame(maxHeight: .infinity)
                }
            }
        }.onAppear {
            if isExamine() {
                selectedOption = "已完成"
            }
        }
    }
}

#Preview {
    CustomVoiceView(viewModel: MakeVoiceViewModel(),viewModelDone: MakeVoiceDoneViewModel())
}
